<form id="dorefund"  class="tableform" method='post' action='index.php?app=ome&ctl=<{$ctl}>&act=<{$act}>&finder_id=<{$env.get.finder_id}>'>
    <input type='hidden' name='order_id' id='order_id' value='<{$order.order_id}>'>
    <input type='hidden' name='shop_id' id='shop_id' value='<{$shop_id}>'>
    <input type='hidden' name='return_id' value='<{$return_id}>'>
    <input type='hidden' name='terminal_tag' value='<{$order.terminal_tag}>'>
	<input type='hidden' name='order_bn' value='<{$order.order_bn}>'>
	<input type='hidden' name='remain_cancel_flag' value='<{$remain_cancel_flag}>'>
	<input type='hidden' name='diff_price' value='<{$diff_price}>'>
	<input type='hidden' name='back_url' id='back_url' value='<{$env.get.back_url}>'>
    <div class="division">
    <{if $is_c2cshop}>
    <div class="notice">该订单为<{$shop_name}>订单,由于目前暂不支持同步退款申请,所以请到对应的销售平台进行实际退款。&nbsp;&nbsp;如继续操作所产生的退款申请单只会在本系统生成不会出现在<{$shop_name}>上。</div>
    <{/if}>      
<table width="100%" cellspacing="0" cellpadding="0" border="0">
    <tr>
    <th><{t}>平台订单号:<{/t}></th>
    <td><{$order.order_bn}> 【<{$pay_status[$order.pay_status];}>】</td>
    <th><{t}>下单日期:<{/t}></th>
    <td><{$order.createtime|cdate:'SDATE_STIME'}></td>
    </tr>
  <tr>
    <th><{t}>订单金额:<{/t}></th>
    <td><span style="color:red;"><b><{$order['total_amount']}></b></span></td>

    <th><{t}>已付金额:<{/t}></th>
    <td><span style='color:red;'><b><{$order.payed}></b></span></td>
    </tr>
  <tr>
    <th><{t}>退款类型: <{/t}></th>
    <td><{input type="radio" name="pay_type" options=$typeList value=$pay_type vtype='requiredradio'}></td>
    <th><{t}>退款支付方式:<{/t}></th>
    <td>
    <{if $payment}>
    <{if $node_id}>
    <select id='payment' name='payment'>
        <{if $payment_id}>
          <{foreach from=$order_paymentcfg key=key item=item}>
            <option value="<{$item.id}>"><{$item.custom_name}></option>
          <{/foreach}>
        <{/if}>
    </select>
    <{else}>
        <{input type="select" id="payment" name='payment' rows=$payment valueColumn="id" labelColumn="custom_name" value=$payment_id }>
    <{/if}>
    <{else}>
    <select id='payment' name='payment'>
    </select>
    <em class="red">请先添加或同步前端店铺支付方式</em>
    <{/if}>
    </td>
  </tr>
    <tr>
    <th><{t}>退款银行:<{/t}></th>
    <td colspan="3"><{input type='text' id='payBank' name='bank' value=$payment_bank width="140"}> <{input id="selectAccount" type="select" name='select_account' options=$pay_account  value=''}></td>
    </tr>
    <tr>
    <th><{t}>退款帐号:<{/t}></th>
    <td><{input type='text' name='account' id='payAccount' value=$account width="140"}></td>
    <th><{t}>收款帐号:<{/t}></th>
    <td><{input type='text' name='pay_account' value=$payment_account width="80"}></td>
  </tr>
  <tr>
       <th><{t}>剩余金额:<{/t}></th>
    <td><span style="color:red;"><b><{$order.payed}></b></span></td>
  </tr>
  <tr>
    <th><{t}>退款金额:<{/t}></th>
    <td colspan="3">
    
    <{if $order.shop_type eq 'bbc'}>
        <{input  readonly='true'  type='text' id='kuaidimoney' vtype="required&&unsigned" name='refund_money' value=$refund_money width="140"}><{input type='hidden' name='return_id' value=$return_id}>
    <{else}>
        <{input  type='text' id='kuaidimoney' vtype="required&&unsigned" name='refund_money' value=$refund_money width="140"}><{input type='hidden' name='return_id' value=$return_id}>
    <{/if}>
  
    
    
    </td>
    </tr>
  <tr <{if $remain_cancel_flag == 'true'}>style="display:none;"<{/if}>  >
  <th><{t}>订单明细:<{/t}></th>
    <td colspan="3">
    <{if count($aItems) > 0}>
   <div class="division">
    <div  class="gridlist">
      <input type='hidden' name='bncheckname' id='bncheckname'>
      <table>
        <thead>
          <th><{t}>基础物料编码<{/t}></th>
          <th><{t}>基础物料名称<{/t}></th>
		   <th><{t}>数量<{/t}></th>
		   <th><{t}>单价<{/t}></th>
        </tr>
      </thead>
      <tbody>
        <{foreach from=$aItems item=aGoods name="item"}>
        <tr <{if $aGoods.delete == 'true'}>style="background-color: rgb(216, 216, 216);"<{/if}>>
          <td><{$aGoods.bn}></td>
          <td class="textleft">
          <{$aGoods.name}>
          </td>
          <td><{$aGoods.quantity}></td>
          <td><{$aGoods.price}></td>
        </tr>
        <{/foreach}>
      </tbody>
      </table>
    </div>
  </div>
    <{/if}>
    </td>
    </tr>
  <tr>
  <th><{t}>申请备注:<{/t}></th>
    <td colspan="3"><{input type="textarea" name="memo"   cols="78" rows="5"}></td>
    </tr>
</table>
</div>
<{area inject=".mainFoot"}>
<div class="table-action">
    <{button label='提交' onclick="return submitchk();" id="ome_register_refund" type="button" class="btn btn-primary"}>
</div>
<{/area}>
</form>
<script>

$$('input[name^=pay_type]').addEvent('click', function(){
    var order_id = $('order_id').value, shop_id = $('shop_id').value, pay_type = this.value;
    W.page('index.php?app=ome&ctl=admin_finance&act=payment_by_pay_type&p[0]='+order_id+'&p[1]='+shop_id+'&p[2]='+pay_type,{update:$('payment'),onComplete:function(){
        if($('payment').length <= 1){
        	$('payment').disabled = 'disabled';
        }else{
            $('payment').disabled = '';
        }
    }});
});

$('ome_register_refund').addEvent('click',function(e){
	$('dorefund').fireEvent('submit',{stop:function(){}});
});
function submitchk(){
 var a = document.getElementsByName("pay_type");
 var b = document.getElementById("bncheckname");
 var c='';
 for(var i = 0 ;i<a.length;i++) {
  if(a[i].checked) {
  c+=a[i].value+',';
  }
 }
 b.value=c;
}
$('selectAccount').addEvent('change', function(e){
  e=new Event(e);
  var ipt=e.target;
  var str = ipt.value;
  var aItems = str.split('-');
  $('payBank').value = aItems[0];
  $('payAccount').value = aItems[1];
});

<{if !$addon.from}>
	$('dorefund').store('target',{
		onRequest:function(e){
	        //提交按钮:disabled
	        $('ome_register_refund').set('disabled', 'true');
	    },
	    onComplete:function(jsontext){
	       var json = Json.evaluate(jsontext);
	       if (typeof(json.error) == 'undefined'){
	    	   $('dorefund').getParent('.dialog').retrieve('instance').close();
	    	   try{
	    		   parent.finderGroup['<{$finder_id}>'].refresh.delay(400,parent.finderGroup['<{$finder_id}>']);
	    	   }catch(e){}
	       }else{
			   //提交按钮:disabled
			   $('ome_register_refund').set('disabled', '');
	       }
	    }
	});
<{/if}>

<{if $addon.from == 'remain_order_cancel'}>
    $('dorefund').store('target',{
        onRequest:function(e){
            //提交按钮:disabled
            $('ome_register_refund').set('disabled', 'true');
            $('ome_register_refund').getElements('span')[1].set('text','正在处理');
        },
        onComplete:function(jsontext){
           var json = Json.evaluate(jsontext);
           var back_from = $('back_from').value;
           var back_find_id = $('back_find_id').value;
           var back_filter = $('back_filter').value;
           $('refund_money').set('value', $('kuaidimoney').value);
           if (typeof(json.error) == 'undefined'){
               $('ome_register_refund').set('disabled', 'true');
               $('ome_register_refund').getElements('span')[1].set('text','正在处理');
               $('ome_remain_cancel_form').fireEvent('submit',{stop:function(){}});
           }else{
               $('ome_register_refund').set('disabled', '');
               $('ome_register_refund').getElements('span')[1].set('text','申请退款');
           }
        }
    });
    function remain_order_cancel_confirm(back_find_id,back_filter){
        if (confirm("余单撤消成功，是否回到确认拆分页面，否则将关闭当前窗口?")){
            var order_id = <{$order.order_id}>;
            window.location = 'index.php?app=ome&ctl=admin_order&act=do_confirm&p[0]='+order_id+'&filter='+back_filter+'&find_id='+back_find_id;
            $('ome_btn_confirm').getParent('.dialog').retrieve('instance').close();
        }else {
            opener.finderGroup[back_find_id].refresh.delay(0,opener.finderGroup[back_find_id]);
            window.close();
        }
    }
<{/if}>

<{if $addon.from == 'order_edit'}>
	$('dorefund').store('target',{
	    onRequest:function(e){
	        //提交按钮:disabled
	        $('ome_register_refund').set('disabled', 'true');
	        $('ome_register_refund').getElements('span')[1].set('text','正在处理');
	    },
	    onComplete:function(jsontext){
	       var json = Json.evaluate(jsontext);
	       if (typeof(json.error) == 'undefined'){
	           $('ome_register_refund').set('disabled', 'true');
	           $('ome_register_refund').getElements('span')[1].set('text','正在处理');
	           $('dorefund').getParent('.dialog').retrieve('instance').close();
	           doAction(2);
	           finish_edit_confirm();
	       }else{
	           $('ome_register_refund').set('disabled', '');
	           $('ome_register_refund').getElements('span')[1].set('text','申请退款');
	       }
	    }
	});
<{/if}>
</script>